#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    int removeDuplicates(vector<int>& nums) {
        int n = nums.size();
        if (n < 2) return n;
        int cur = 2;
        for (int i = 2; i < n; i++)
        {
            if (nums[i] != nums[cur - 2])
                nums[cur++] = nums[i];
        }
        return cur;
    }
};